package io.conversion;

import java.io.*;
import java.nio.charset.Charset;

public class inputStream {
//    转换流：是字符流和字节流之间的桥梁
//    字节流想要试用字符流的方法
public static void main(String[] args) throws IOException {
/*被淘汰了
//    创建对象并指定字符编码
    InputStreamReader isr=new InputStreamReader(new FileInputStream("b.txt"),"UTF-8");
//    读取数据
    int ch;
    while ((ch= isr.read())!=-1){
        System.out.println((char)ch);
    }
//    释放资源
    isr.close();*/
    FileReader fr=new FileReader("b.txt", Charset.forName("UTF-8"));

//    读取数据
    int ch;
    while ((ch= fr.read())!=-1){
        System.out.println((char)ch);
    }
//    释放资源
    fr.close();
//    将GBK转为UTF-8
    InputStreamReader isr=new InputStreamReader(new FileInputStream(""),"GBK");
    OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream(""),"UTF-8");
}
}
